@extends('layouts._admin')

@section('title')
	商品列表
@endsection

@section('content')
	<div class="app-content">
		<div ui-butterbar></div>
		<a href class="off-screen-toggle hide" data-toggle="class:off-screen" data-target=".app-aside"></a>
		<div class="app-content-body fade-in-up">
			<!-- COPY the content from "tpl/" -->
			<div class="hbox hbox-auto-xs hbox-auto-sm">
				<div class="col">
					<div class="wrapper-md ng-scope">
						<div class="panel panel-default">
							<div class="panel-heading">
								商品列表
							</div>
							<div class="table-responsive">
								<div id="DataTables_Table_0_wrapper" class="dataTables_wrapper form-inline dt-bootstrap no-footer">
									<div class="panel-body">
										@if ($message = Session::get('success'))
											<div class="alert alert-success">
												<p>{{ $message }}</p>
											</div>
										@endif

										@if ($message = Session::get('error'))
											<div class="alert alert-danger">
												<p>{{ $message }}</p>
											</div>
										@endif


										<a href="{{ route('admin.article.create') }}">
											<button type="button" class="btn btn-sm btn-primary">
												<i class="glyphicon glyphicon-plus"></i>
												添加文章
											</button>
										</a>

									</div>
									<div class="row">

										<div class="col-sm-12">
											<table ui-jq="dataTable" ui-options="{sAjaxSource: 'api/datatable.json',aoColumns: [{ mData: 'engine' },{ mData: 'browser' },{ mData: 'platform' },{ mData: 'version' },{ mData: 'grade' }]}" class="table table-striped b-t b-b dataTable no-footer" id="DataTables_Table_0" role="grid" aria-describedby="DataTables_Table_0_info">
												<thead>
												<tr role="row">
													<th style="width: 100px;" class="sorting" tabindex="0"
														aria-controls="DataTables_Table_0" rowspan="1" colspan="1">序号</th>
													<th style="width: 213px;" class="sorting" tabindex="0" aria-controls="DataTables_Table_0" rowspan="1" colspan="1">标题</th>
													<th style="width: 213px;" class="sorting" tabindex="0" aria-controls="DataTables_Table_0" rowspan="1" colspan="1">描述</th>
													<th style="width: 213px;" class="sorting" tabindex="0" aria-controls="DataTables_Table_0" rowspan="1" colspan="1">分类</th>
													<th style="width: 213px;" class="sorting" tabindex="0" aria-controls="DataTables_Table_0" rowspan="1" colspan="1">关键词</th>
													<th style="width: 213px;" class="sorting" tabindex="0" aria-controls="DataTables_Table_0" rowspan="1" colspan="1">封面</th>
													<th style="width: 213px;" class="sorting" tabindex="0" aria-controls="DataTables_Table_0" rowspan="1" colspan="1">观看</th>
													<th style="width: 213px;" class="sorting" tabindex="0" aria-controls="DataTables_Table_0" rowspan="1" colspan="1">添加时间</th>
													<th style="width: 250px;" class="sorting" tabindex="0"
														aria-controls="DataTables_Table_0" rowspan="1" colspan="1">操作</th>
												</tr>
												</thead>
												<tbody>
												@foreach ($articles as $key => $article)
													<tr role="row" class="odd">
														<td>{{$article->article_id}}</td>
														<td>{{$article->title}}</td>
														<td>{{$article->describe}}</td>
														<td>{{$article->hasOneCategory->cate_name}}</td>
														<td>{{$article->key_word}}</td>
														<td><img src="{{$article->cover}}" alt="" width="100" height="100"></td>
														<td>{{$article->look}}</td>
														<td>{{$article->created_at}}</td>
														<td>
															<a class="btn btn-info" href="1">Show</a>
															<a class="btn btn-success" href="{{route('admin.article.edit',$article->article_id)}}">Edit</a>
															<a class="btn btn-danger" data-toggle="modal" data-target="#myModal{{$article->article_id}}" href="javascript:;">Delete</a>
														</td>
													</tr>
													{{--模态框--}}
													<div class="modal fade" id="myModal{{$article->article_id}}" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
														<div class="modal-dialog">
															<div class="modal-content">
																<div class="modal-header">
																	<button type="button" class="close" data-dismiss="modal" aria-hidden="true">
																		&times;
																	</button>
																	<h4 class="modal-title" id="myModalLabel">
																		确定删除{{$article->title}}此文章吗?
																	</h4>
																</div>
																<div class="modal-body">
																	注:删除后无法找回
																</div>
																<div class="modal-footer">
																	<button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>

																	{!! Form::open(['method' => 'DELETE','route' => ['admin.article.destroy', $article->article_id],'style'=>'display:inline']) !!}
																	{!! Form::submit('删除', ['class' => 'btn btn-danger']) !!}
																	{!! Form::close() !!}
																</div>
															</div><!-- /.modal-content -->
														</div><!-- /.modal -->
													</div>

												@endforeach
												</tbody>
											</table>
										</div>
									</div>
									<div class="row">
										<div class="col-sm-6">
											<div class="dataTables_info text-height" id="DataTables_Table_0_info"
												 role="status" aria-live="polite">当前第{{$articles->currentPage()}}页,
												共{{$articles->total()}}个条目</div>
										</div>
										<div class="col-sm-6">
											{!! $articles->render() !!}
										</div>
									</div>
								</div>
							</div>
						</div>
					</div>
				</div>
			</div>
		</div>
	</div>
@endsection

